﻿<?php include COMMON_PATH.'/share/header.html' ?>
    <script src="/share/js/sdk/TcPlayer-2.2.1.js"></script>
    <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
    <link rel="stylesheet" href="/index/js/swiper/swiper.min.css">
    <link rel="stylesheet" href="/share/css/live.css">
    <cross-domain-policy>
        <allow-access-from domain="*.qq.com" secure="false"/>
    </cross-domain-policy>
</head>

<body>
<div class="main">
    <!--回放wrap-->
    <div id="back_video" class="common-wrap" style="width:100%; overflow: hidden;">
        <h3 class="share-title" style="">
            liveTraining
        </h3>
        <section class="top">
            <div class="top-left-wrap">
                <img class="host-avatar" src="<?=$info['avatar']?>"  onerror = "imgNoFind(this)">
                <article class="info">
                    <span class="host-name"><?=$info['nickname']?></span>
                    <span class="fans-num"><?=$info['viewing']?></span> 次观看
                </article>
            </div>
        </section>
        <span class="play-btn" ></span>

    </div>
    <div id="pass-in" style=" display:none; width: 100%; height: 100%; line-height: 100%; text-align: center; vertical-align: middle; background: rgb(136, 136, 136); position: absolute;top: 0; left: 0; z-index: 1002;">
        <span style="position: absolute;top: 50%;left: 0;width: 100%; color: #fff;"></span>
    </div>

</div>
<script type="text/javascript" src="/index/js/swiper/swiper.min.js"></script>
<script src="/share/js/jquery.min.js"></script>
<script src="/share/js/common.js"></script>
<script src="/share/js/mui.min.js"></script>
<script src="/share/js/jrrpc.js"></script>
<script>

    function getLogInfo (){
        var loginInfo = {
            'sdkAppID': "1400043256",
            'appIDAt3rd': "1400043256",
            'accountType': "17845",
        };
        return loginInfo;
    }

    var my_swiper = new Swiper('.swiper-container', {
        nextButton: '.swiper-button-next',
        prevButton: '.swiper-button-prev',
        pagination: '.swiper-pagination',
        observer:true,
        observeParents:true,
        loop:false,
        paginationType: 'fraction',
        onInit: function(swiper){
        }
    });
    var password = "<?=$info['password']?>";
    sessionStorage.sharepassword = 2;
    if(password!=0){
        $('#pass-in').show();
        function successFunc(data){
            console.log(data);
            if(data.code==200){
                $('#pass-in').hide();
            }else
            if(data.code == 400){
                mui.alert(data.data.message,' ',function(){
                    sessionStorage.sharepassword = '1';
                    checkPassword();
                });
                return false;
            }
        }
        function checkPassword(){
            mui.prompt('','请输入观看密码','请输入观看密码',['确认'],function(e){
                if (e.index == 0) {
                    var param = {
                        postData:'share/meeting/password',
                        data:{
                            mid:"<?=$info['mid']?>",
                            password:$('input[type=password]').val()
                        }
                    };
                    $.JsonRpc(param, successFunc);
                }
            },'div');
            document.querySelector('.mui-popup-input input').autocomplete='new-password';
            document.querySelector('.mui-popup-input input').type='password';
            $(document.querySelector('.mui-popup-input input')).attr({maxlength:"6"});
        }
        checkPassword();
    }else {
        $('#pass-in').hide();
    }
    $(function(){
        mui.init();
        var
                play_btn = $(".play-btn"),
                icon_ppt = $(".icon-ppt"),
                swiper_wrap = $(".swiper-out-wrap"),
//                flag = IsPC(),
                live_width = 0,
                live_height = 0,
                screen_height = window.screen.height,
                andr_height = screen_height - 20,
                inner_height = window.innerHeight,
                video_height = inner_height,
                u = navigator.userAgent,
                isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1,
                isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/),
                play_wrap = 'back_video';
        var ppt_flag = "<?=$info['annex']?>";

        icon_ppt.on('click',function(){
            if($(this).hasClass('icon-close')){
                swiper_wrap.hide();
                $(this).removeClass('icon-close')
            }else {
                swiper_wrap.show();
                $(this).addClass('icon-close')
            }
        });

        var option = {
            "width" :  live_width,
            "height" : andr_height
        };

        if(iService.getUserAgent().isPC){
            option.height = inner_height;
            option.width = option.height*9/16;
            $(".main").width(option.width).css({"position":"relative","overflow":"hidden"});
        }else if(iService.getUserAgent().isiOS){
            //如果要统一app中的高度，可以设置为innerheight，但是不为全屏，类似快手
            option.height = inner_height;
            live_flv_url = "";
        }

        var player =  new TcPlayer(play_wrap, {
            "m3u8": "<?=$url['transcodeList'][0]['url']?>",
            "flv":  "<?=$url['transcodeList'][1]['url']?>", //增加了一个flv的播放地址，用于PC平台的播放
            "autoplay" : false,      //iOS下safari浏览器是不开放这个能力的
            "coverpic" : {"style": "stretch", "src": "<?=$info['image']?>"},
            "controls":'default',
            "live": false,
            "x5_player":true,
            "x5_type":"h5",
            "x5_fullscreen":true,
            "width" :  option.width,
            "height" : option.height,
            listener: function (msg) {
                if(msg.type == 'error'){
                    window.setTimeout(function(){
                    },5000);
                }
                var player_vcp = $(".vcp-player"),
                        player_video = $("video");
                function playToggle (){
                    if(player.playing()){
                        play_btn.hide();
                        icon_ppt.show();
                    }else {
                        play_btn.show();
                        if(icon_ppt.hasClass('icon-close')){
                            icon_ppt.removeClass('icon-close');
                        }
                        icon_ppt.hide();
                        swiper_wrap.hide();
                    }
                }
                playToggle();
                play_btn.off("touchend mousedown").on("touchend mousedown",function(){
                    player.play();
                });

            }
        });

    });
</script>
<?php include COMMON_PATH.'/share/footer.html' ?>
</body>
</html>